<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>电子书城</title>
<link rel="stylesheet" href="css/main.css" type="text/css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.8.3.js"></script>
<script type="text/javascript">
function add(sdss,id,pum,mum){
    var ss = "#"+"quantity"+sdss;
    var  t =$(ss)
    var  min="#"+"min"+sdss;
    var  add="#"+"add"+sdss;
    var  total="#"+"total"+sdss;
    var  jage="#"+"jage"+sdss;
    if(id==1){
    	if(parseInt(t.val())<mum){
    		t.val(parseInt(t.val())+1);    
    	    $("#min"+sdss).removeAttr("disabled");     
    	}else{    
            $("#min").attr("disabled","disabled")        //当$("#min")为1时，$("#min")不可读状态    
        }
    	$("#total").html($("#total").text+pum);
    	$(total).html(parseInt(t.val())*pum);
    	var zong=parseInt($("#zong").val());
        $("#zong1").html(zong+pum);
        $("#zong").val(zong+pum);
    }else{
        if (parseInt(t.val())>1) {                     //判断数量值大于1时才可以减少    
             t.val(parseInt(t.val())-1)
             $("#min"+sdss).removeAttr("disabled");
        }else{    
             $("#min").attr("disabled","disabled")        //当$("#min")为1时，$("#min")不可读状态    
       } 
    $(total).html(parseInt(t.val())*pum);
    var zong=parseInt($("#zong").val());
    $("#zong1").html(zong-pum);
    $("#zong").val(zong-pum);
    }     
}
	</script>


</head>


<body class="main">
	<jsp:include page="head.jsp" />

	<jsp:include page="menu_search.jsp" />

	<div id="divpagecontent">
		<table width="100%" border="0" cellspacing="0">
			<tr>

				<td><div style="text-align:right; margin:5px 10px 5px 0px">
						<a href="index.jsp">首页</a>&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;<a
							href="cart.jsp">&nbsp;购物车</a>&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;订单
					</div>

					<form id="orderForm" action="OrderServlet?id=1" method="post">
						<table cellspacing="0" class="infocontent">
							<tr>
								<td><table width="100%" border="0" cellspacing="0">
										<tr>
											<td><img src="images/buy2.gif" width="635" height="38" />
												<p>您好：xxx先生！欢迎您来到商城结算中心</p></td>
										</tr>
										<tr>
											<td><table cellspacing="1" class="carttable">
													<tr>
														<td width="10%">序号</td>
														<td width="40%">商品名称</td>
														<td width="10%">价格</td>
														<td width="10%">类别</td>
														<td width="10%">数量</td>
														<td width="10%">小计</td>

													</tr>
												</table>

												<table width="100%" border="0" cellspacing="0">
												<%
    int num=0;
	Cookie[] allCookie = request.getCookies();
    Cookie userCookie = null;
    if (allCookie != null) {
        for (Cookie c : allCookie) {
        	System.out.println(c.getName());
            if ("iop".equals(c.getName())) {
                userCookie = c; 
            }
        }
    }
    if (userCookie!=null){
	
        int a=0;
		String str = userCookie.getValue();
		String [] p = str.split("/");
        for(int i=0; i<p.length; i++){
        	String[] u = p[i].split("@");
        	num=num+(Integer.parseInt(u[2])*Integer.parseInt(u[3]));
        		%>
												  <tr>
													<td width="10%"><%=a%></td>
													<td width="30%"><%=u[1]%></td>

														<td width="10%" id="jage<%=a%>"><%=u[0]%></td>
														<td width="20%">
														<input type="button" value='-'
															style="width:20px" id="min<%=a%>" onclick="add(<%=a%>,2,<%=u[0]%>,<%=u[2]%>)"> 

															<input name="text" id="quantity<%=a%>" type="text"  value="<%=u[3]%>"
															style="width:40px;text-align:center" /><input
															type="button" value='+' style="width:20px" id="add<%=a%>" onclick="add(<%=a%>,1,<%=u[0]%>,<%=u[2]%>)">

														</td>
														<td width="10%" ><%=u[2]%></td>
														<td width="10%" id="total<%=a%>"><%=u[0]%></td>

														<td width="10%"><a href="#"
															style="color:#FF0000; font-weight:bold" >X</a></td>
													</tr>
    		<%
        	a++;
        }
    }
	%>
												</table>


												<table cellspacing="1" class="carttable">
													<tr>
														<td style="text-align:right; padding-right:40px;"><font
															style="color:#FF0000">合计：&nbsp;&nbsp;<input type="hidden" name="money" value="<%=num%>" id="zong" >
														<a  id="zong1"><%=num%></a>元</font></td>
													</tr>
												</table>

												<p>
													收货地址：<input name="receiverAddress" type="text" value="xxx"
														style="width:350px" />&nbsp;&nbsp;&nbsp;&nbsp;<a href="#"></a>
													<br /> 收货人：&nbsp;&nbsp;&nbsp;&nbsp;<input
														name="receiverName" type="text" value="xxx"
														style="width:150px" />&nbsp;&nbsp;&nbsp;&nbsp;<a href="#"></a>
													<br /> 联系方式：<input type="text" name="receiverPhone"
														value="xxx" style="width:150px" />&nbsp;&nbsp;&nbsp;&nbsp;

												</p>
												<hr />
												<p style="text-align:right">
												<input
									type="image" src="images/gif53_029.gif"  width="204" height="51" border="0">
												</p></td>
										</tr>
									</table></td>
							</tr>
						</table>
					</form></td>
			</tr>
		</table>
	</div>


	<jsp:include page="foot.jsp" />


</body>
</html>
